package com.yksj.healthtalk.ui.setting;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.yksj.healthtalk.comm.BaseFragmentActivity;
import com.yksj.healthtalk.ui.R;
import com.yksj.healthtalk.ui.app.AppUpdateManager;
import com.yksj.healthtalk.ui.app.HTalkApplication;
import com.yksj.healthtalk.utils.SystemUtils;
import com.yksj.healthtalk.utils.ToastUtil;
/**
 * 关于壹健康
 * @author root
 *
 */
public class SettingAboutHealthActivity extends BaseFragmentActivity implements OnClickListener {
	private FragmentManager fragmentManager;
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.setting_about_health_layout);
		initView();
	}

	private void initView() {
		initTitle();
		titleLeftBtn.setOnClickListener(this);
		titleTextV.setText("关于壹健康");
		TextView versionNumber=(TextView) findViewById(R.id.version_number);
		versionNumber = (TextView) findViewById(R.id.version_number);
		versionNumber.setText("壹健康 4.1.1");
		//SystemUtils.getAppVersionName(SettingAboutHealthActivity.this)
		findViewById(R.id.setting_grade).setOnClickListener(this);
		findViewById(R.id.setting_update).setOnClickListener(this);
		findViewById(R.id.setting_make).setOnClickListener(this);
		findViewById(R.id.setting_jieshao).setOnClickListener(this);
		fragmentManager = getSupportFragmentManager();
	}

	@Override
	public void onClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case R.id.title_back:
			finish();
			break;
		case R.id.setting_grade://给壹健康平分吧
			SystemUtils.commentGood(this);
			break;
		case R.id.setting_update://检查更新
			updateApp();
			break;
		case R.id.setting_make://用户条款与隐私协议
			intent=new Intent(this,SettingWebUIActivity.class);
			intent.putExtra("title", "用户协议与隐私条款");
			intent.putExtra("url",HTalkApplication.getApplication().getUserAgentPath());
			startActivity(intent);
			overridePendingTransition(R.anim.anim_enter,R.anim.anim_exit);
			break;
		case R.id.setting_jieshao://版本说明
			intent=new Intent(this,SettingWebUIActivity.class);
			intent.putExtra("title", "版本说明");
			intent.putExtra("TextSize", 100);
			intent.putExtra("url",HTalkApplication.getApplication().getFunctionIntroduction() );
			startActivity(intent);
			break;
		}
	}
	
	/**
	 * 更新程序
	 */
	private void updateApp() {
		if (!HTalkApplication.getApplication().isNetWork()) {
			ToastUtil.showToastPanl("网络无效");
			return;
		}
		new AppUpdateManager(this,true).checkeUpdate();
	}
}
